From 2a335a7802c96150b4778470dedffd8d521a105c Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Thu, 2 Mar 2006 14:43:24 +0100 Subject: [PATCH] A few changes to the new 'guest handle' interface: DEFINE_GUEST_HANDLE -> define_guest_handle GUEST_HANDLE -> guest_handle New __define_guest_handle allows handle name different from encapsulated type's name (useful for awkward typenames). Got rid of xen_ulong, now use guest_handle(ulong). Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 2 +- xen/arch/x86/x86_32/mm.c | 2 +- xen/arch/x86/x86_64/mm.c | 2 +- xen/common/memory.c | 10 +++++----- xen/include/asm-x86/mm.h | 4 ++-- xen/include/public/memory.h | 16 ++++++++-------- xen/include/public/xen.h | 24 +++++++++++++++--------- xen/include/xen/guest_access.h | 2 +- xen/include/xen/sched.h | 2 +- 9 files changed, 35 insertions(+), 29 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 60a324cf79..60e8e778b5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2788,7 +2788,7 @@ long do_update_descriptor(u64 pa, u64 desc) } -long arch_memory_op(int op, GUEST_HANDLE(void) arg) +long arch_memory_op(int op, guest_handle(void) arg) { struct xen_reserved_phys_area xrpa; unsigned long pfn; diff --git a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c index 19dfc0170e..2df32d9d8f 100644 --- a/xen/arch/x86/x86_32/mm.c +++ b/xen/arch/x86/x86_32/mm.c @@ -192,7 +192,7 @@ void subarch_init_memory(struct domain *dom_xen) } } -long subarch_memory_op(int op, GUEST_HANDLE(void) arg) +long subarch_memory_op(int op, guest_handle(void) arg) { struct xen_machphys_mfn_list xmml; unsigned long mfn; diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 7e826da8b0..2a61d41324 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -183,7 +183,7 @@ void subarch_init_memory(struct domain *dom_xen) } } -long subarch_memory_op(int op, GUEST_HANDLE(void) arg) +long subarch_memory_op(int op, guest_handle(void) arg) { struct xen_machphys_mfn_list xmml; l3_pgentry_t l3e; diff --git a/xen/common/memory.c b/xen/common/memory.c index 4d96f97465..3c0320ee39 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -31,7 +31,7 @@ static long increase_reservation( struct domain *d, - GUEST_HANDLE(xen_ulong) extent_list, + guest_handle(ulong) extent_list, unsigned int nr_extents, unsigned int extent_order, unsigned int flags, @@ -80,7 +80,7 @@ increase_reservation( static long populate_physmap( struct domain *d, - GUEST_HANDLE(xen_ulong) extent_list, + guest_handle(ulong) extent_list, unsigned int nr_extents, unsigned int extent_order, unsigned int flags, @@ -141,7 +141,7 @@ populate_physmap( static long decrease_reservation( struct domain *d, - GUEST_HANDLE(xen_ulong) extent_list, + guest_handle(ulong) extent_list, unsigned int nr_extents, unsigned int extent_order, unsigned int flags, @@ -198,7 +198,7 @@ decrease_reservation( static long translate_gpfn_list( - GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress) + guest_handle(xen_translate_gpfn_list_t) uop, unsigned long *progress) { struct xen_translate_gpfn_list op; unsigned long i, gpfn, mfn; @@ -257,7 +257,7 @@ translate_gpfn_list( return 0; } -long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg) +long do_memory_op(unsigned long cmd, guest_handle(void) arg) { struct domain *d; int rc, op, flags = 0, preempted = 0; diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 040d919626..1a65b04161 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -380,7 +380,7 @@ void propagate_page_fault(unsigned long addr, u16 error_code); int __sync_lazy_execstate(void); /* Arch-specific portion of memory_op hypercall. */ -long arch_memory_op(int op, GUEST_HANDLE(void) arg); -long subarch_memory_op(int op, GUEST_HANDLE(void) arg); +long arch_memory_op(int op, guest_handle(void) arg); +long subarch_memory_op(int op, guest_handle(void) arg); #endif /* __ASM_X86_MM_H__ */ diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 639c293b27..e923731fbd 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -29,7 +29,7 @@ typedef struct xen_memory_reservation { * OUT: GMFN bases of extents that were allocated * (NB. This command also updates the mach_to_phys translation table) */ - GUEST_HANDLE(xen_ulong) extent_start; + guest_handle(ulong) extent_start; /* Number of extents, and size/alignment of each (2^extent_order pages). */ unsigned long nr_extents; @@ -50,7 +50,7 @@ typedef struct xen_memory_reservation { domid_t domid; } xen_memory_reservation_t; -DEFINE_GUEST_HANDLE(xen_memory_reservation_t); +define_guest_handle(xen_memory_reservation_t); /* * Returns the maximum machine frame number of mapped RAM in this system. @@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list { * any large discontiguities in the machine address space, 2MB gaps in * the machphys table will be represented by an MFN base of zero. */ - GUEST_HANDLE(xen_ulong) extent_start; + guest_handle(ulong) extent_start; /* * Number of extents written to the above array. This will be smaller @@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list { */ unsigned int nr_extents; } xen_machphys_mfn_list_t; -DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t); +define_guest_handle(xen_machphys_mfn_list_t); /* * Returns the base and size of the specified reserved 'RAM hole' in the @@ -115,7 +115,7 @@ typedef struct xen_reserved_phys_area { /* Base and size of the specified reserved area. */ unsigned long first_gpfn, nr_gpfns; } xen_reserved_phys_area_t; -DEFINE_GUEST_HANDLE(xen_reserved_phys_area_t); +define_guest_handle(xen_reserved_phys_area_t); /* * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error @@ -130,15 +130,15 @@ typedef struct xen_translate_gpfn_list { unsigned long nr_gpfns; /* List of GPFNs to translate. */ - GUEST_HANDLE(xen_ulong) gpfn_list; + guest_handle(ulong) gpfn_list; /* * Output list to contain MFN translations. May be the same as the input * list (in which case each input GPFN is overwritten with the output MFN). */ - GUEST_HANDLE(xen_ulong) mfn_list; + guest_handle(ulong) mfn_list; } xen_translate_gpfn_list_t; -DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t); +define_guest_handle(xen_translate_gpfn_list_t); #endif /* __XEN_PUBLIC_MEMORY_H__ */ diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index a629a1e26a..907ac5cc6b 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -10,19 +10,25 @@ #define __XEN_PUBLIC_XEN_H__ #ifdef __XEN__ -#define DEFINE_GUEST_HANDLE(type) struct __guest_handle_ ## type { type *p; } -#define GUEST_HANDLE(type) struct __guest_handle_ ## type +#define __define_guest_handle(name, type) \ + typedef struct { type *p; } __guest_handle_ ## name #else -#define DEFINE_GUEST_HANDLE(type) -#define GUEST_HANDLE(type) type * +#define __define_guest_handle(name, type) \ + typedef type * __guest_handle_ ## name #endif +#define define_guest_handle(name) __define_guest_handle(name, name) +#define guest_handle(name) __guest_handle_ ## name + #ifndef __ASSEMBLY__ -/* Guest handle for unsigned long pointer. Define a name with no whitespace. */ -typedef unsigned long xen_ulong; -DEFINE_GUEST_HANDLE(xen_ulong); -/* Guest handle for arbitrary-type pointer (void *). */ -DEFINE_GUEST_HANDLE(void); +/* Guest handles for primitive C types. */ +__define_guest_handle(uchar, unsigned char); +__define_guest_handle(uint, unsigned int); +__define_guest_handle(ulong, unsigned long); +define_guest_handle(char); +define_guest_handle(int); +define_guest_handle(long); +define_guest_handle(void); #endif #if defined(__i386__) diff --git a/xen/include/xen/guest_access.h b/xen/include/xen/guest_access.h index 3a5bba9f0b..d824421bf0 100644 --- a/xen/include/xen/guest_access.h +++ b/xen/include/xen/guest_access.h @@ -18,7 +18,7 @@ /* Cast a guest handle to the specified type of handle. */ #define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ - (GUEST_HANDLE(type)) { _x }; \ + (guest_handle(type)) { _x }; \ }) /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2d9c5564d1..3acd0d79a0 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -311,7 +311,7 @@ void startup_cpu_idle_loop(void); * 'i' [unsigned] {char, int} * 'l' [unsigned] long * 'p' pointer (foo *) - * 'h' guest handle (GUEST_HANDLE(foo)) + * 'h' guest handle (guest_handle(foo)) */ unsigned long hypercall_create_continuation( unsigned int op, const char *format, ...); -- 2.30.2